package com.jstide.credit.data.service.biz;

import cn.hutool.core.util.StrUtil;
import cn.hutool.db.Entity;
import com.jstide.credit.data.service.Algorithm;
import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.ResultSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;

public class Factor6_7 extends Algorithm {

    public static final Logger logger = LoggerFactory.getLogger(Factor6_7.class);

    @Getter
    public final  String name="6_7";

    //最高学历
    //“研究生”30分；“本科”20分；“大专”15分；“高中”10分；“初中”5；“小学”3分；无不给分
    //博士10分
    @Getter
    public  final String sql =" select ZGXL,ZGXW from  ZRRJYXX where join_id=@joinId   ";

    //@Getter
   // public final int defaultScore=30;

    @Override
    public int translate(String rs) {
        return 0;
    }



    @Override
    public int translate(List<Entity> rs) {
        if(null!=rs && rs.size()>0) {
            return educationalScore(rs) + degreeScore(rs);
        }
        return 0;
    }


    private int educationalScore(List<Entity> rs){
       int score;
       score = rs.stream().filter(t-> StrUtil.equals( t.getStr("ZGXL"),"研究生")).count()>0?30:0;

       if(0==score){
           score = rs.stream().filter(t-> StrUtil.equals( t.getStr("ZGXL"),"本科")).count()>0?20:0;
       }
       if(0==score){
            score = rs.stream().filter(t-> StrUtil.equals( t.getStr("ZGXL"),"大专")).count()>0?15:0;
       }
       if(0==score){
            score = rs.stream().filter(t-> StrUtil.equals( t.getStr("ZGXL"),"高中")).count()>0?10:0;
       }
       if(0==score){
            score = rs.stream().filter(t-> StrUtil.equals( t.getStr("ZGXL"),"初中")).count()>0?5:0;
       }
        return score;
    }

    private int degreeScore (List<Entity> rs){
        return  rs.stream().filter(t-> StrUtil.equals( t.getStr("ZGXW"),"博士")).count()>0?10:0;
    }
}
